package com.key.w8.http1.connection.environment;

import lombok.Data;

/**
 * @Author: k8
 * @CreateTime: 2025-03-06
 * @Version: 1.0
 */
@Data
public class ConnectionEnvironment {
    private final boolean isServer;
    private static final String CLASS_PATH = ConnectionEnvironment.class.getClassLoader().getResource("").getPath();
    public static final int DEFAULT_MAX_THREADS = 1000;
    public static final int DEFAULT_MAX_CONNECTIONS = 1000;    // 默认最大连接数
    public static final long DEFAULT_CONNECTION_TIMEOUT = 90*1000;  // 默认连接超时时间（30秒）
    public static final long DEFAULT_HEARTBEAT_INTERVAL = 30*1000;

    public static final String DEFAULT_CRT_PATH = CLASS_PATH+"private/cert.pem";
    public static final String DEFAULT_PRIVATE_KEY_PATH = CLASS_PATH+"private/key.pem";

    public static final int DEFAULT_RECONNECT_TIMES = 3;


    private int maxConnections = DEFAULT_MAX_CONNECTIONS;     // 最大连接数
    private long connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;  // 连接超时时间
    private boolean keepAlive = false;



    private String crtPath = DEFAULT_CRT_PATH;                // SSL证书路径
    private String privateKeyPath = DEFAULT_PRIVATE_KEY_PATH;
    //默认30秒
    private long heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL;//心跳间隔

    private boolean reConnect = true;
    private int reConnectTimes = DEFAULT_RECONNECT_TIMES;
    private int maxThreads = DEFAULT_MAX_THREADS;


    public boolean isServer(){
        return this.isServer;
    }

    public ConnectionEnvironment(boolean isServer) {
        this.isServer = isServer;
    }
}
